|
|
|
|
|
|
|
3. The default size of a Microsoft Jet TEXT field is 255 bytes. |
|
|
|
|
|
|
|
|
4. You use the ALTER TABLE_ADD COLUMN statement to add a column to a table. The ALTER TABLE_ADD COLUMN statement uses the following format: |
|
|
|
|
|
|
|
|
ALTER TABLE <Name of Table> ADD COLUMN <Name of column> <Type> <Size>; |
|
|
|
|
|
|
|
|
5. You use the DROP TABLE statement to remove a table from a database. The DROP TABLE statement uses the following format: |
|
|
|
|
|
|
|
|
6. You create indexes to data tables with the CREATE INDEX SQL statement. |
|
|
|
|
|
|
|
|
7. The following are the three forms of the CONSTRAINT clause: |
|
|
|
 |
|
|
|
|
·PRIMARY KEY |
|
|
|
 |
|
|
|
|
·UNIQUE |
|
|
|
 |
|
|
|
|
·FOREIGN KEY |
|
|
|
|
|
|
|
|
Answer to Day 13 Exercise |
|
|
|
|
|
|
|
|
Enter the following code to build the CustomerType and Customers tables. Please note that the CustomerType table must be built before the Customers table, because of the foreign key constraint on CustomerType in the Customers table. |
|
|
|
|
|
|
|
|
// Create the database
dbmake C:\CUSTOMER\CH13EX.MDB;
// Build the Customer Types Table
CREATE TABLE CustomerType(
CustomerType TEXT(6) CONSTRAINT PKCustomerType PRIMARY KEY,
Description TEXT(30));
// Build the Customers table
CREATE TABLE Customers(
CustomerID TEXT(10) Constraint PKCustomerID PRIMARY KEY,
Name TEXT(30),
CustomerType TEXT(6) CONSTRAINT FKCustomerType
_REFERENCES CustomerType(CustomerType),
Address TEXT(30),
City TEXT(30),
State TEXT(30),
Zip TEXT(10),
Phone TEXT(14),
Fax TEXT(14));
// Build the index on Zip
CREATE INDEX SKZip on Customers(Zip);
//Display the results
SELECT * FROM CustomerType;
SELECT * FROM Customers; |
|
|
|
|
|